using System;
using System.Collections.Generic;
using SharpArch.Core.DomainModel;

namespace AgileBoard.Core
{
    public class Iteration : Entity
    {
        public Iteration()
        {
            States = new List<State>();
            Stories = new List<Story>();
        }

        public virtual IList<State> States { get; set; }
        public virtual IList<Story> Stories  { get; set;} 

        public virtual string Label { get; set; }

        public virtual DateTime Start { get; set; }

        public virtual DateTime Finish { get; set; }

        public virtual Project Project { get; set; }

        public virtual void AddState(State state)
        {
            States.Add(state);
            state.Iteration = this;
        }

        public virtual void RemoveState(State state)
        {
            States.Remove(state);
            state.Iteration = null;
        }

        public virtual void AddStates(IList<StateTemplate> defaultStates)
        {
            foreach (var stateTemplate in defaultStates)
            {
                AddState(new State(){
                    Label = stateTemplate.Label,
                    OrderIndex = stateTemplate.OrderIndex
                });
            }
        }
    }
}